package main

import (
	"fmt"
	"os"

	"gopkg.in/yaml.v3"
)

// Config 定义配置结构体
type Config struct {
	Port int    `yaml:"port"`
	Host string `yaml:"host"`
}

var config Config

// Setup 初始化配置
func Setup() {
	yamlFile, err := os.ReadFile("config.yaml")
	if err != nil {
		fmt.Printf("Error reading YAML file: %v\n", err)
		return
	}

	err = yaml.Unmarshal(yamlFile, &config)
	if err != nil {
		fmt.Printf("Error unmarshaling YAML: %v\n", err)
		return
	}
	fmt.Printf("Configuration loaded: %+v\n", config)
}

func main() {
	Setup()
	// 后续可以使用配置进行其他操作
	fmt.Printf("Listening on %s:%d\n", config.Host, config.Port)
}
